package login.processor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import game.module.user.ProtoMessageLogin.S2CAnnouncement;
import lion.common.MsgCodeAnn;
import lion.netty4.message.GamePlayer;
import lion.netty4.message.MyRequestMessage;
import lion.netty4.message.MySendToMessage;
import lion.netty4.message.RequestMessageRaw;
import lion.netty4.message.RequestProtoMessage;
import lion.netty4.processor.MsgProcessor;
import login.LoginServer;

@MsgCodeAnn(msgcode = 10027, accessLimit = 500)
public class GetAnnouncementProcessor extends MsgProcessor {

	private static Logger logger = LoggerFactory.getLogger(GetAnnouncementProcessor.class);

	@Override
	public void process(GamePlayer player, RequestMessageRaw request) throws Exception {
		logger.info("get announcement!");
	}

	@Override
	public void process(GamePlayer player, RequestProtoMessage request) throws Exception {
		logger.info("get announcement!");
		String content = LoginServer.getInstance().getLoginServerConfig().getAnnouncement();
		player.writeAndFlush(10028, S2CAnnouncement.newBuilder().setContent(content));
	}

	@Override
	public void process(GamePlayer gamePlayer, MyRequestMessage request) throws Exception {
		logger.info("get announcement!");
		String content = LoginServer.getInstance().getLoginServerConfig().getAnnouncement();
		MySendToMessage retMsg = new MySendToMessage(gamePlayer.alloc(), 10028);
		retMsg.writeString(content);
		gamePlayer.writeAndFlush(retMsg);
	}

}
